package com.itedge.solutionmanager.domain.impl;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Version;

import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.itedge.infrastructure.domain.IEntity;
import com.itedge.solutionmanager.enumeration.DocCategory;

@Entity
@Table(name="DOCUMENT")
public class Document implements IEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;	
    
	@Version
    @Column(name = "version")
    private Integer version;

    @Enumerated(EnumType.ORDINAL)
    @Column(name="CATEGORY")
    private DocCategory category;      
    
    @Lob @Column(name = "BYTES")
    private byte[] bytes;
    
    @Column(name = "NAME")
    private String name;
    
    @Column(name = "CONTENT_TYPE")
    private String contentType;   
    
    //private CommonsMultipartFile fileData;
    
    @Override
	public Long getId() {
        return this.id;
    }

	public void setId(Long id) {
        this.id = id;
    }  
  
    public DocCategory getCategory()
    {
        return category;
    }

    public void setCategory(DocCategory category)
    {
        this.category = category;
    }  
    
    public void setFileData(CommonsMultipartFile fileData)
    {
        //this.fileData = fileData;
        this.contentType = fileData.getContentType();
        this.bytes = fileData.getBytes();
        this.name = fileData.getOriginalFilename();
    }
    
    public CommonsMultipartFile getFileData() {
    	return null;
    }

	public byte[] getBytes() {
		return bytes;
	}

	public void setBytes(byte[] bytes) {
		this.bytes = bytes;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
	@Override
	public Integer getVersion() {
		return this.version;
	}
  
}